package com.decapre.springbootdemo.controller;

import com.decapre.springbootdemo.entity.Office;
import com.decapre.springbootdemo.service.OfficeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "Office controller")
@RestController
@RequestMapping("/office")
public class OfficeController {

    private OfficeService officeService;

    @Autowired
    public OfficeController(OfficeService officeService){
        this.officeService = officeService;
    }

    @GetMapping("/index")
    @ApiOperation("getAllOffice")
    public List<Office> getAllOffice(){
        return officeService.getAllOffice();
    }

    @GetMapping("/{officeId}")
    @ApiOperation(("getOfficeById"))
    public Office getOfficeById(@PathVariable int officeId){
        return officeService.getOfficeById(officeId);
    }
}
